package com.cssw.fyzb.wap.controller;

import com.cssw.fyzb.base.web.context.UserContext;
import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.wap.model.dto.GExchangeFDto;
import com.cssw.fyzb.wap.model.dto.YExchangeFDto;
import com.cssw.fyzb.wap.model.vo.GExchangeFDefVo;
import com.cssw.fyzb.wap.model.vo.GExchangeFVo;
import com.cssw.fyzb.wap.model.vo.YExchangeFDefVo;
import com.cssw.fyzb.wap.service.ExchangeService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/exchange")
public class ExchangeController {
    @Autowired
    private ExchangeService exchangeService;

    /**
     * 音值兑换福币
     *
     * @return
     */
    @ApiOperation(value = "音值兑换福币", response = AjaxData.class)
    @ApiImplicitParam(name = "dto", value = "音值兑换福币", dataType = "YExchangeFDto")
    @RequestMapping(value = "yExchangeF", method = RequestMethod.POST)
    public AjaxData yExchangeF(@RequestBody YExchangeFDto dto) {
        return exchangeService.yExchangeF(UserContext.getUserId(), dto.getNum(), dto.getYfId(), dto.getType(), dto.getPwd());
    }

    /**
     * 音值兑换福币列表
     */
    @ApiOperation(value = "音值兑换福币列表", response = AjaxData.class)
    @RequestMapping(value = "yExchangeFDef", method = RequestMethod.GET)
    public AjaxPage<YExchangeFDefVo> yExchangeFDefList() {
        return exchangeService.yExchangeFDefList();
    }


    /**
     * 果子兑换福币
     *
     * @return
     */
    @ApiOperation(value = "果子兑换福币", response = AjaxData.class)
    @ApiImplicitParam(name = "dto", value = "果子兑换福币", dataType = "GExchangeFDto")
    @RequestMapping(value = "gExchangef", method = RequestMethod.POST)
    public AjaxData<GExchangeFVo> gExchangeF(@RequestBody GExchangeFDto dto) {
        return exchangeService.gExchangeF(UserContext.getUserId(), dto.getNum(), dto.getLogId(), dto.getType(), dto.getPwd());
    }


    /**
     * 果子兑换福币
     */
    @ApiOperation(value = "果子兑换福币列表", response = AjaxData.class)
    @RequestMapping(value = "gExchangeFDef", method = RequestMethod.GET)
    public AjaxPage<GExchangeFDefVo> gExchangeFDefList() {
        return exchangeService.GExchangeFDefList();
    }


}
